package com.itheima.service;

import com.itheima.dao.UserRepository;
import com.itheima.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {
    @Autowired
    private UserRepository userRepository;
    public List<User> findAll(){
        return userRepository.findAll();
    }
    public List<User> findByUsername(String username){return userRepository.findByUsernameContaining(username);}

    public User loginUser(String username,String password){
        return userRepository.findUserAndPassword(username,password);
    }
    public User loginUser(User user){
        return userRepository.findUserAndPassword(user.getUsername(),user.getPassword());
    }
}
